package com.fzy.silntgym.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.fzy.silntgym.R;
import com.fzy.silntgym.application.UserAgent;


public class AccountActivity extends AppCompatActivity {
    TextView nickname;
    TextView rank;
    TextView signature;
    TextView sex;
    TextView level;
    TextView credits;
    ImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_account);
        nickname = (TextView) findViewById(R.id.nickname_info);
        rank = (TextView)findViewById(R.id.rank_info);
        signature = (TextView)findViewById(R.id.signature_info);
        sex = (TextView)findViewById(R.id.sex_info);
        level = (TextView)findViewById(R.id.level_info);
        credits = (TextView)findViewById(R.id.credits_info);
        imageView = (ImageView)findViewById(R.id.imageView4);
        Button logout = (Button)findViewById(R.id.logout);
        if(UserAgent.islogin){
            nickname.setText("昵称: "+ " "+ UserAgent.getNickname());
            rank.setText("称号："+" "+UserAgent.getRank());
            signature.setText("签名： "+" "+UserAgent.getSignature());
            sex.setText("性别： "+" "+UserAgent.getSex());
            level.setText("等级 ："+" "+UserAgent.getLevel());
            credits.setText("积分： "+" "+UserAgent.getCredits());
            imageView.setImageDrawable(getResources().getDrawable(R.drawable.portrait_login));
            Toast.makeText(this,"用户信息已拉取",Toast.LENGTH_SHORT).show();
        }
        if (logout != null) {
            logout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    nickname.setText("昵称: ");
                    rank.setText("称号：");
                    signature.setText("签名： ");
                    sex.setText("性别： ");
                    level.setText("等级 ：");
                    credits.setText("积分： ");
                    UserAgent.islogin  = false;
                    finish();
                    Toast.makeText(getApplicationContext(),"您已登出！",Toast.LENGTH_SHORT).show();
                }
            });
        }

    }


}
